This invention relates generally to the translation of computer programs and more specifically to a system that ensures that accurate translation occurs in view of software mechanisms that can cause file incompatibilities or other program structural problems in generating a desired translation.
Computer program, or "code," translators are useful for translating a computer program written in a first language (the "original," or "source" language) into a second language (the "target" language). For example, some older languages may become unpopular or outdated making their programs difficult to support because of lack of skilled programmers, lack of compatible computers to execute the code, etc. Or, a company or user of original source code may wish to translate the code to be in the same language as other programs, or to migrate the code to a computer system that doesn't support the original language.
However, the accurate translation of today's computer languages into a target language is made extremely difficult because of "text preprocessor mechanisms." Such mechanisms, such as "include" statements, macros, and conditional compiles, cause changes to the text of a program so that the ultimate program is not discernable from a simple "face value" parsing of the text of the program. Moreover, the program text can change depending on different conditions existing at the time the program is "built" or compiled.
For example, an "include" statement is a common feature of most of today's popular computer languages. Such a statement, when encountered in a computer program, directs the compiler to fetch the text from another file and insert it into the file currently being compiled. Thus, although the include statement is a single line naming an external file, it effectively inserts any amount of computer program instructions into a computer program.
A "macro" is a similar device that can act as a function call that becomes embedded anywhere in the text of the computer program. A macro can be "defined" to be a complicated function of several lines of text that is invoked whenever a designated symbol is used anywhere within the computer program. Thus, the symbol "ID" can be defined to be a macro such as "average(b+daytime, array[15])" so that whenever the symbol "ID" appears in the program, it will be substituted for its definition (i.e., a "macro expansion"). Macros are even more problematic to code translations because macros can be defined to accept parameters that, in turn, need to be inserted in the definition of the macro when it is expanded.
Finally, conditional compile statements allow any number of lines of code to be "conditional compiles" that are only compiled into the final program if the condition is true. For example, one condition can be if "debug=TRUE" then compile the next 200 lines of code. Otherwise the 200 lines of code will not be present in the compiled program.
Other text preprocessor mechanisms are possible. Any text preprocessor mechanism that can alter the program code from its "face value" listing can pose major problems to a translator because the translator can no longer assume that the original code can map line-for-line, or even routine-for-routine or file-for-file, into a target translation. Although such text preprocessor mechanisms allow efficient and compact writing of code, and provide flexible control to programmers, these mechanisms are a major obstacle to code translators.
Thus, it is desirable to provide a system that efficiently ensures that accurate translation of computer programs can take place even in the face of such text preprocessor mechanisms.